﻿using SqlSugar;

using System;

namespace Repositorys
{
    internal class DefaultEntity
    {
        /// <summary>
        /// 添加时的默认实体字段
        /// </summary>
        /// <param name="entityInfo"></param>
        internal static void InsertDefaultEntity(DataFilterModel entityInfo)
        {
            var key = entityInfo.PropertyName;

            switch (key)
            {
                case "id":
                    entityInfo.SetValue(Guid.NewGuid());
                    break;
                case "create_user":
                    entityInfo.SetValue("lierlin");
                    break;
                case "create_time":
                    entityInfo.SetValue(DateTime.Now);
                    break;
                case "is_delete":
                    entityInfo.SetValue(0);
                    break;
            }
           ;
        }
        /// <summary>
        /// 修改时的默认实体字段
        /// </summary>
        /// <param name="entityInfo"></param>
        internal static void UpdateDefaultEntity(DataFilterModel entityInfo)
        {
            var (key, value) = (entityInfo.PropertyName, new object());

            switch (key)
            {
                case "update_user":
                    entityInfo.SetValue("lierlin1");
                    break;
                case "update_time":
                    entityInfo.SetValue(DateTime.Now);
                    break;
            }
        }

    }
}
